package com.example.demo.service;

import com.example.demo.mapper.ArticleMapper;
import com.example.demo.model.ArticleInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleService {
    @Autowired
    private ArticleMapper articleMapper;
    public List<ArticleInfo> articleInfoList(Integer uid){
        return articleMapper.getAllById(uid);
    }

    public  ArticleInfo getDetails(Integer id){
        return articleMapper.getDetails(id);
    }

    public int update(Integer aid,Integer uid,String title,String content ){
        return articleMapper.update(aid,uid,title,content);
    }

    public List<ArticleInfo> getList(Integer pindex,Integer offset){
        return articleMapper.getList(pindex, offset);
    }

    public Integer getTotalPage(){
        return articleMapper.getTotalPage();
    }

    //根据作者名查询文章数量
    public Integer getCountArticleByName(Integer uid){
        return articleMapper.getCountArticleByName(uid);
    }
    public int insert(Integer uid, String title,  String content){
        return articleMapper.insert(uid,title,content);
    }

    //根据文章id删除文章
    public Integer deleteArtById(Integer id){
        return  articleMapper.deleteArtById(id);
    }


}
